<template>
    <div>
        <el-page-header @back="goBack" content="角色与权限"></el-page-header>
        <!-- 表单 -->
		<el-form ref="form" :model="form" size="small"  label-width="80px">
            <el-form-item label="角色编号">
                <el-input v-model="form.roleId"></el-input>
            </el-form-item>
                <el-form-item label="权限编号">
                <el-input v-model="form.privilegeId"></el-input>
            </el-form-item>
            <el-form-item label="">
                <div style="text-align:right">
                    <!-- submitHandler：提交处理器 -->
                    <el-button type="primary" size="small" @click="submitHandler">提交</el-button>
                </div>
            </el-form-item>
        </el-form>
    </div>
</template>
<script>
import { post } from '@/utils/request'
export default {
    data(){ 
        return {
			form:{}
        }
    },
    methods:{
        // 提交
        submitHandler(){
            let url = "http://localhost:8888/roleprivilege/saveOrUpdate"
            // post方法从import { get } from '@/utils/request'获得（要导包）
            post(url,this.form).then(resp =>{
                // 获取前端请求数据之后做的事情
                // 弹出提示：获取保存成功后后台给前端的更新成功信息，要注意我们后台response除了有message还有data和status
                this.$message({type:"success",message:resp.message})
                // 返回列表页面
                this.goBack();
            })
        },
		//返回
		goBack(){
            this.$router.go(-1)
        }
    },
    created(){
            this.form = this.$route.query;
    }
}
</script>
<style lang="sass" scoped>

</style>